Repository navigation
docs: run the production server with bun scripts/serve.ts - #152
Merged
Merged
Conversation
With Bun 1.4.2's default system shell, `bun run start` and `bun start` deliver one terminal Ctrl+C to the server twice (the terminal signals the foreground group and `bun run` forwards it as npm does), so adapter-bun treats it as a second signal and exits 1 at once without the SHUTDOWN_TIMEOUT drain. A group SIGTERM is doubled the same way. `NODE_ENV=production bun scripts/serve.ts` receives each signal once. Point README and CLAUDE.md at the direct command, say why, and keep the SHUTDOWN_TIMEOUT and SIGHUP notes accurate. The `start` package script and all code are unchanged. Signed-off-by: edbfi <326875205+edbfi@users.noreply.github.com>
There was a problem hiding this comment.
ℹ️ No issues found. This is a docs-only change and I have no suggestions.
Reviewed changes
I read the full diff of README.md and CLAUDE.md and checked it against package.json, scripts/serve.ts and scripts/serve.test.ts.
- README Production Startup: Replaces
bun run startwith abun run buildandNODE_ENV=production bun scripts/serve.tscode block. It explains thatbun run startandbun startdeliver one Ctrl+C twice and skip theSHUTDOWN_TIMEOUTdrain. - README
SHUTDOWN_TIMEOUTrow: Scopes "a secondSIGTERM/SIGINTexits at once" to the direct command and notes that the first Ctrl+C already does underbun run start. - CLAUDE.md Commands: The production command is now the direct one, with the reason not to use
bun run start. - CLAUDE.md Deployment and origin: The
SIGHUPnote now says the hangup arrives twice underbun run startand once under the direct command. It also says a Ctrl+C or groupSIGTERMarrives twice underbun run start, which forces exit 1 without the drain.
The new text is consistent with the repo:
- The command shown matches the
startscript inpackage.json(NODE_ENV=production bun scripts/serve.ts). - The double-
SIGHUPdescription matches the comments atscripts/serve.ts:272andscripts/serve.test.ts:887. - A search for
bun run startandbun startfound no other references to update. - Both docs that
CLAUDE.mdsays to keep in step (CLAUDE.mdand theREADME.mdenv table) were updated together.
I did not reproduce the Bun 1.4.2 signal-forwarding behaviour. The PR's validation table is the only evidence for it.
claude-sonnet-5-5 | 𝕏
edbfi
added a commit
that referenced
this pull request
Oct 7, 2026
…153) The SIGHUP comments in scripts/serve.ts and scripts/serve.test.ts explain the double hangup under `bun run start`. Keep that and add that the production command, `NODE_ENV=production bun scripts/serve.ts`, gets it once, as CLAUDE.md says since #152. Comment only. Signed-off-by: edbfi <326875205+edbfi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
The README and
CLAUDE.mdtell people to start the production server withbun run start. With Bun 1.4.2's default system shell,bun run startandbun startdeliver one terminal Ctrl+C to the server twice: the terminal signals the foreground process group, andbun runalso forwards the signal to its child, as npm does. adapter-bun 1.0.0 treats the second delivery as a second signal (graceful_shutdowncallsprocess.exit(1)when it is already shutting down), so a single Ctrl+C exits 1 at once with noSHUTDOWN_TIMEOUTdrain: in-flight requests are cut andsveltekit:shutdownnever runs, so the scheduler is not stopped. A groupSIGTERMis doubled the same way (a repeatedSIGHUPis already ignored by the front since #151).NODE_ENV=production bun scripts/serve.ts, which is what thestartscript runs, receives each signal once.This PR changes the documented production command to
NODE_ENV=production bun scripts/serve.tsand says why. It is docs only: thestartpackage script,scripts/serve.ts, the tests and Playwright (which already runsbun scripts/serve.ts) are unchanged.Changes
README.md, Production Startup: a code block withbun run buildandNODE_ENV=production bun scripts/serve.ts, followed by one line explaining whybun run startandbun startare not used. The note that thestartscript runs the same command stays.README.md,SHUTDOWN_TIMEOUTrow: same meaning; "A secondSIGTERM/SIGINTexits at once" now says it holds withNODE_ENV=production bun scripts/serve.ts(underbun run startthe first Ctrl+C already does).CLAUDE.md, Commands: the production command isNODE_ENV=production bun scripts/serve.ts, with the reason not to usebun run start.CLAUDE.md, Deployment and origin: theSIGHUPnote now says the hangup arrives twice underbun run startand once under the direct command, and that a Ctrl+C or groupSIGTERMalso arrives twice underbun run start, which forces exit 1 without the drain, with or withoutORIGIN. The line namingscripts/serve.tsas the entry ofstart, Playwright and the container image is unchanged (still accurate)..env.example(SHUTDOWN_TIMEOUTdrains onSIGTERM/SIGINT) names no start command and stays as is. A search of every tracked doc,.env.exampleandCLAUDE.md/AGENTS.md(a symlink toCLAUDE.md) forbun run start,bun start,npm startandrun startfinds no other place.Rationale
Changing how
bun runlaunches the script (a bunfig[run] shell = "bun"or--shell=bun) was considered and not chosen: under the Bun shell,SIGTERM/SIGHUPsent to the launcher PID kill the launcher and orphan the server (oven-sh/bun#41802, an open PR, addresses that). The system-shell double forwarding is intentional npm parity in Bun (oven-sh/bun#36711). Running the front directly avoids both. This is the same change as edbfi/poyo-studio#90.Validation
Real build of
mainatd82d4ff(this branch's base; the branch changes no code), Bun 1.4.2 on macOS 27.0.1, 2026-10-07. Each launch runs in its own process group on a free loopback port, with a privateTMPDIR, its own copy of a seeded database andSHUTDOWN_TIMEOUT=3. After/api/healthanswers, one formPOST /loginis kept in flight (curl uploads its body slowly), then the whole group is signalled as a terminal does. "Drain" means the adapter waited for the request andsveltekit:shutdownran (scheduler.stoppedlogged).ORIGINbun run startSIGINT(Ctrl+C)scheduler.stopped)bun startSIGINTNODE_ENV=production bun scripts/serve.tsSIGINTscheduler.stopped)NODE_ENV=production bun scripts/serve.tsSIGINT, again 1 s laterbun run startSIGTERMNODE_ENV=production bun scripts/serve.tsSIGTERMbun run startSIGINTsveltekit:shutdownnever ran)NODE_ENV=production bun scripts/serve.tsSIGINTscheduler.stopped)In the two rows without
ORIGINthe app refused the probe's POST with 403 (no front, so the origin check did not match), so those rows show only the exit andsveltekit:shutdown. No case left a listener or a socket directory.bun run startreportederror: script "start" exited with code 1in every case.Local gates on head
d153fb5(the repository has no application CI; Pullfrog is the only workflow):prek run --from-ref origin/main --to-ref HEAD: every applicable hook passed (whitespace, end of file, line endings, merge conflicts, case conflicts, large files, private keys, branch guard, gitleaks,svelte checkviabun run check:types); JSON/TOML/YAML andbiome checkwere skipped because no such file changed.prek run --hook-stage commit-msg: Conventional Commit passed.bun run check(Biome): exit 0, no fixes (3 warnings and 42 infos, all in source files this PR does not touch);bunx biome format .: exit 0, no fixes.git diff origin/main --stat:README.mdandCLAUDE.mdonly.